"use strict";
//abstract定义抽象类，不能被new 实例化
class Package {
    //构造方法
    constructor(weight) {
        this.weight = weight;
    }
    //具体实现
    printPackage() {
        console.log(`包裹的重量是${this.weight}kg,运费为：${this.calculate()}元 `);
    }
}
class StandardPackage extends Package {
    //unitPrice这边必须写修饰符，否则会报错
    constructor(weight, unitPrice) {
        super(weight);
        this.unitPrice = unitPrice;
    }
    // calculate()继承了抽象类，这边是给抽象方法一个具体实现
    calculate() {
        return this.weight * this.unitPrice; //unitPrice这边必须写修饰符，否则会报错
    }
}
class ExpressPackage extends Package {
    //unitPrice这边必须写修饰符，否则会报错
    constructor(weight, unitPrice, //特快单价比普通要高的单价
    additional //超出的重加收费
    ) {
        super(weight);
        this.unitPrice = unitPrice;
        this.additional = additional;
    }
    // calculate()继承了抽象类，这边是给抽象方法一个具体实现
    calculate() {
        if (this.weight > 10) {
            return 10 * this.unitPrice + (this.weight - 10) * this.additional;
        }
        else {
            return this.weight * this.unitPrice;
        }
    }
}
const s = new StandardPackage(10, 5);
s.printPackage(); //普通包裹的重量是10kg,运费为：50元
console.log(s.calculate()); //50
const e = new ExpressPackage(13, 8, 2);
e.printPackage(); //特快包裹的重量是13kg,运费为：86元
